package com.hzlj.position.locate.dao;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fz.common.base.converter.QueryWrapperConverterPlus;
import com.hzlj.position.locate.common.dto.differentiationConfig.DifferentiationConfigQueryResultDTO;
import com.hzlj.position.locate.common.model.DifferentiationConfig;
import com.hzlj.position.locate.mapper.DifferentiationConfigMapper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * 独立业务-配置(DifferentiationConfig)表操作类
 *
 * @author makejava
 * @date 2024-05-28 11:02:04
 */
@Repository
public class DifferentiationConfigDao extends ServiceImpl<DifferentiationConfigMapper, DifferentiationConfig> {
    @Resource
    private DifferentiationConfigMapper differentiationConfigMapper;

    public DifferentiationConfigQueryResultDTO getConfig(String type, String jgCode) {
        return QueryWrapperConverterPlus.of(differentiationConfigMapper)
                .selectOne(DifferentiationConfigQueryResultDTO.class, null, null, q -> q
                        .apply("'" + jgCode + "' LIKE CONCAT(jg_code, '%')")
                        .eq(DifferentiationConfig::getType, type)
                        .orderByDesc(DifferentiationConfig::getJgCode)
                );
    }
}

